package com.czmh.etc.interpreter.entity.base;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * Created by Huangyk on 2019/6/4.
 */
public abstract class HeaderBase {
    public static String getStringFromBytes(byte[] bytes, int pos, int len){
        try {
            byte[] armArrs = HeaderBase.getSubBytes(bytes, pos, len);
            String output = new String(armArrs, InterpreterContent.CHARACTER_SET);

            return output;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        return "";
    }

    public static byte[] getSubBytes(byte[] bytes, int pos, int len)
    {
        byte[] ret = new byte[len];
        System.arraycopy(bytes, pos, ret, 0, len);
        return ret;
    }
}
